﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using xfsale.lib;
using xfsale.ui;

namespace xfsale.ui.acct
{
    public partial class FrmTransAcctOpen : FrmBase
    {
        public FrmTransAcctOpen()
        {
            InitializeComponent();
        }

        private void BtnOk_Click(object sender, EventArgs e)
        {
            string password = null;
            if (!InputPassword(out password))
            {
                return;
            }

            try
            {
                SetProcParamIn("TradePassword", password);

                //BindProcParamsIn();                
                CallProc();
                //BindProcParamsOut();

                if (returnCode == "0000")
                {
                    //string orderSerialNo = GetProcParamOut("OrderSerialNo");
                    string transAccountID = GetProcParamOut("TransAccountID");
                    SysMessage.Info("{0} 交易帐号: {1}", returnMsg, transAccountID);
                }
                else
                {
                    SysMessage.Error("ERR-{0} {1}", returnCode, returnMsg);
                }
            }
            catch (Exception ex)
            {
                SysMessage.Error(ex.Message);
            }
        }

        private void BtnClose_Click(object sender, EventArgs e)
        {
            CloseFrame();
        }

        private void RadInvst_Click(object sender, EventArgs e)
        {
            if (sender == RadCustTypeIndi) //选择个人
            {
                SetCtrlVal(CmbCustType, "1");
                InitCtrl(CmbCertType, "IndiCertType");
            }
            else if (sender == RadCustTypeInst) //选择机构
            {
                SetCtrlVal(CmbCustType, "0");
                InitCtrl(CmbCertType, "InstCertType");
            }
        }

        private void FrmAcctTransOpen_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                InitFrame();
                InitCtrl(CmbCertType, "IndiCertType");
            }
        }

        private void TxtInvstName_TextChanged(object sender, EventArgs e)
        {
            TxtCustNameAbbr.Text = TxtCustName.Text;
            TxtBankAcctName.Text = TxtCustName.Text;
        }

        private void BtnClear_Click(object sender, EventArgs e)
        {
            RadCustTypeIndi.Checked = true;
            InitCtrl(CmbCertType, "IndiCertType");
            ResetFrame();
        }
    }
}
